package com.tedu.boot.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;


/**
 * @date 2023/4/19
 * @author liuhuan
 */
@Configuration
@EnableSwagger2WebMvc
@Slf4j
public class Knife4jConfiguration {

    public Knife4jConfiguration() {
        log.info("Knife4J初始化成功");
    }

    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("接口文档")
                .description("学茶接口文档")
                .termsOfServiceUrl("待定")
                .contact(new Contact("","",""))
                .version("1.0")
                .build();
    }

    @Bean
    public Docket createRestApi(ApiInfo apiInfo){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .groupName("学茶")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tedu.adapter.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
